﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class JobSearchAdvanced : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Fillddls();

        }
    }
    protected void btnAdvancedSeach_Click(object sender, EventArgs e)
    {
        string sk, ind, fun, minexp, maxexp, jobl;
        string redirectlink = "";
        string mode = clsEncryptionDecryption.EncryptQueryString("Advanced");
        if (Request.QueryString["roleid"] != null)
            redirectlink = "JobSearchResult.aspx?roleid=" + Request.QueryString["roleid"].ToString() + "&mode=" + mode + "&";
        else
            redirectlink = "JobSearchResult.aspx?";
        sk = txtKeySkills.Text.Trim().ToLower();
        ind = txtIndustry.Text.Trim().ToLower();
        if (ddlFunctionalArea.SelectedIndex != 0)
            fun = ddlFunctionalArea.SelectedValue;
        else
            fun = null;
        if (ddlMinExpRequired.SelectedIndex != 0)
            minexp = ddlMinExpRequired.SelectedValue;
        else
            minexp = null;
        if (ddlMaxExpRequired.SelectedIndex != 0)
            maxexp = ddlMaxExpRequired.SelectedValue;
        else
            maxexp = null;
        if (ddlJobLocation.SelectedIndex != 0)
            jobl = ddlJobLocation.SelectedValue;
        else
            jobl = null;
        if (sk != "")
            redirectlink = redirectlink + "skillset=" + clsEncryptionDecryption.EncryptQueryString(sk) + "&";
        if (ind != "")
            redirectlink = redirectlink + "&industryset=" + clsEncryptionDecryption.EncryptQueryString(ind) + "&";
        if (fun != null)
            redirectlink = redirectlink + "&functionalarea=" + clsEncryptionDecryption.EncryptQueryString(fun) + "&";
        if (minexp != null)
            redirectlink = redirectlink + "&minexperience=" + clsEncryptionDecryption.EncryptQueryString(minexp) + "&";
        if (maxexp != null)
            redirectlink = redirectlink + "&maxexperience=" + clsEncryptionDecryption.EncryptQueryString(maxexp) + "&";
        if (jobl != null)
            redirectlink = redirectlink + "&joblocation=" + clsEncryptionDecryption.EncryptQueryString(jobl) + "&";
        redirectlink = redirectlink.Remove(redirectlink.Length - 1, 1);
        Response.Redirect(redirectlink);

    }
    protected void btnClearSearch_Click(object sender, EventArgs e)
    {
        try
        {
            txtKeySkills.Text = "";

        }
        catch (Exception)
        {

            throw;
        }
    }

    protected void Fillddls()
    {
        try
        {
            // Project Location
            clsCity objclsCity = new clsCity();
            List<IN_TB_CITY> objIN_TB_CITY = new List<IN_TB_CITY>();
            objIN_TB_CITY = objclsCity.GetAllCities();
            ddlJobLocation.Items.Clear();
            ddlJobLocation.AppendDataBoundItems = true;
            ddlJobLocation.DataTextField = "CITY";
            ddlJobLocation.DataValueField = "ID";
            ddlJobLocation.Items.Add("Select");
            ddlJobLocation.Items[0].Value = "0";
            ddlJobLocation.DataSource = objIN_TB_CITY;
            ddlJobLocation.DataBind();

            // Functional Area
            clsFunctionalAreaDAL objclsFunctionalAreaDAL = new clsFunctionalAreaDAL();
            List<IN_TB_FUNCTIONAL_AREA> objIN_TB_FUNCTIONAL_AREA = new List<IN_TB_FUNCTIONAL_AREA>();
            objIN_TB_FUNCTIONAL_AREA = objclsFunctionalAreaDAL.GetAllFunctionalAreas();
            ddlFunctionalArea.Items.Clear();
            ddlFunctionalArea.AppendDataBoundItems = true;
            ddlFunctionalArea.DataTextField = "FUNCTIONAL_AREA";
            ddlFunctionalArea.DataValueField = "ID";
            ddlFunctionalArea.Items.Add("Select");
            ddlFunctionalArea.Items[0].Value = "0";
            ddlFunctionalArea.DataSource = objIN_TB_FUNCTIONAL_AREA;
            ddlFunctionalArea.DataBind();

            //Min Experience Required
            ddlMinExpRequired.Items.Clear();
            ddlMinExpRequired.AppendDataBoundItems = true;
            ddlMinExpRequired.Items.Add("Select");
            ddlMinExpRequired.Items[0].Value = "0";
            for (int i = 1; i <= 90; i++)
            {
                ddlMinExpRequired.Items.Add(i.ToString());
                ddlMinExpRequired.Items[i].Value = i.ToString();
            }
            ddlMinExpRequired.DataBind();

            // Max Experience Required
            ddlMaxExpRequired.Items.Clear();
            ddlMaxExpRequired.AppendDataBoundItems = true;
            ddlMaxExpRequired.Items.Add("Select");
            ddlMaxExpRequired.Items[0].Value = "0";
            for (int i = 1; i <= 90; i++)
            {
                ddlMaxExpRequired.Items.Add(i.ToString());
                ddlMaxExpRequired.Items[i].Value = i.ToString();
            }
            ddlMaxExpRequired.DataBind();
        }
        catch (Exception)
        {

            throw;
        }
    }
}